<template>
  <BaseDialog ref="baseDialog" width="50%" title="选择设备" @confrim="confrim">
    <vxe_table
      :options="options"
      @handleTableBtn="handleTableBtn"
      ref="baseTable"
    >
    </vxe_table>
  </BaseDialog>
</template>

<script>
import { getDeviceList } from "@/api/device";
import vxe_table from "@/components/table/vxe_table.vue";
import tableMixin from "@/mixins";
export default {
  mixins: [tableMixin],
  components: {
    vxe_table,
  },
  data() {
    return {
      options: {
        id: "usertable",
        apiFn: getDeviceList,
        hideExport:true,
        columns: [
          {
            field: "imei",
            title: "IMEI",
            search: true,
            valueType: "input",
          },

          {
            field: "brand",
            title: "品牌",
          },
          { field: "osVer", title: "版本" },
          { field: "model", title: "模式" },
          {
            field: "state",
            title: "用户状态",
            type: "html",
            formatter: ({ row }) => {
              if (row.state) {
                return "<span style='color:green'>在线</span>";
              } else {
                return "<span style='color:red'>离线</span>";
              }
            },
          },
        ],
        btn: [
          {
            title: "选择设备",
            handleName: "handleSelect",
          },
        ],
      },
    };
  },
  methods: {
    open() {
      this.$refs.baseDialog.open();
    },
    confrim() {
      this.close();
    },
    close() {
      this.$refs.baseDialog.close();
    },
    handleSelect(row){
        this.$emit('select',row)
      this.close();
    }
  },
};
</script>
